package org.jin.samples.dao.impl;

import java.util.Date;

import org.jin.samples.dao.IManageStudentDao;
import org.jin.samples.model.ExamRole;
import org.jin.samples.model.ExamUser;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

@Repository
@Transactional
public class ManageStudentDao extends BaseHibernateDAO<ExamUser> implements IManageStudentDao{
	
	@Override
	public ExamUser getUserById(String userId) throws Exception {
		try{
			ExamUser user = this.get(userId);
			if(user != null){
				for(ExamRole role : user.getExamRole()){
					
				}
			}
			return user;
		}catch (Exception e) {
			System.out.println("not find user");
			return null;
		}
	}
	
	
	@Override
	public void add(ExamUser user){	
		user.setPassword("123");
		user.setLoginFailCount(0);
		user.setLastLockTime(new Date());
		this.save(user);
	}
	
}
